﻿<?php  
class ControllerPageMessage extends Controller {
	public function index() {
	
		$this->data['heading_title'] = 'Whoslab';
		
		$this->data['action']=$this->url->link('page/message');
		
		$this->load->model('page/message');
		
		
		if(($this->request->server['REQUEST_METHOD'] == 'POST')){
			$this->model_page_message->saveMessage($this->request->post);
			$this->session->data['success']="留言成功！";
		}
		
		
		//getall messages
		$this->data['messages']=$this->model_page_message->getAllMessages();
		
		
		if (isset($this->session->data['success'])) {
			$this->data['success'] = $this->session->data['success'];
			
			unset($this->session->data['success']);
		} else {
			$this->data['success'] = '';
		}

		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/page/message.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/page/message.tpl';
		} else {
			$this->template = 'default/template/page/message.tpl';
		}
		
		$this->children = array(
			'common/footer',
			'common/header'
		);
										
		$this->response->setOutput($this->render());
	}
}
?>
